<template>

    <div class="wrapper">
      <div class="contentDiv">
        <img @mousedown="(e) => $emit('onWidgetMouseDown',e,widgetImg)"  draggable="true" :src="user.avatarUrl">
      </div>
        <div
            class="menuItem"
            v-for="(widget,i) in widgetList"
            :key="widget.type"
            draggable="true"
            @mousedown="(e) => $emit('onWidgetMouseDown',e,widget)"
            @dragover.prevent
        >
          <svg-icon  :icon-class="widget.type" className="icon"></svg-icon>
          {{ widget.label }}
        </div>
        <div
            class="buttonMenuItem"
        >
          <el-upload action="http://localhost:9090/file/upload"  :on-success="upload"  style="display: inline-block" :show-file-list="false" >
            <button style="width: 100%;height: 100%;border:0px;background-color: transparent;color: white"><i class="el-icon-document-add"></i>导入</button>
          </el-upload>
        </div>
    </div>


</template>

<script>

import * as CONFIG from "@/constant/config";

export default {
  data(){
    return {
      user: localStorage.getItem("user")?JSON.parse(localStorage.getItem("user")):{},
      widgetImg:CONFIG.WIDGET_IMG,
    }
  },
  props: {
    widgetList:Array,
  },
  methods:{
    upload(res){
      this.$emit('upload',res)
    },
  }
}
</script>

<style scoped>
img{
  opacity:1.0
}
.wrapper{
  z-index: 999;
  background:#1b1c2d;
  display: flex;
  flex-wrap:wrap;
  box-shadow: 1px 0 8px 0 rgba(0, 0, 0, 0.2);
  left: 50%;
  transform:translate(-60%);
  bottom:0;
  height: 30px;
  position: absolute;
  margin-left: 20px;
  border-radius: 10px;
  padding-left: 20px;
  padding-top: 10px;
  padding-bottom: 20px;
}

.menuItem{
  display: flex;
  flex-direction: column;
  margin-right: 20px;
  font-size: 12px;
  width:35px;
  height: 35px;
  text-align: center;
  cursor:pointer;
  color: white;
  padding:3px;
  box-shadow:0 0 4px #ccc;
}

.buttonMenuItem{
  display: flex;
  flex-direction: column;
  margin-right: 20px;
  font-size: 12px;
  text-align: center;
  cursor:pointer;
  color: white;
  height: 100%;
  box-shadow:0 0 4px #ccc;
}
.contentDiv{
  display:inline-block;
  width: 40px;
  height:40px;
  border-radius:100px;
  overflow: hidden;
  border:2px solid #fff;
  box-shadow:0 0 4px #ccc;
  margin-right: 20px;
}
.contentDiv img{
  width:100%;
  min-height:100%;
}

</style>